package edu.kit.aifb.ldstream.learner.dao;

import java.io.Serializable;

import org.openrdf.model.URI;



public class Instance implements Serializable{

	private static final long serialVersionUID = 1273621949613437300L;

	private URI uri;
	
	private int indegree = 0;
	private int outdegree = 0;
	
	transient private int numOccurrence = 1;
	
	public Instance(URI uri){
		this.uri = uri;
	}
	
	public URI getURI(){
		return this.uri;
	}
	
	public void setIndegree(int indegree) {
		this.indegree = indegree;
	}

	public void setOutdegree(int outdegree) {
		this.outdegree = outdegree;
	}

	public int getOccurrence(){
		return this.numOccurrence;
	}
	
	public void incrementOccurence(){
		this.numOccurrence++;
	}
	
	public int getIndegree(){
		return this.indegree;
	}
	
	public int getOutdegree(){
		return this.outdegree;
	}
	
	public void incrementIndegree(){
		this.indegree++;
	}
	
	public void incrementOutdegree(){
		this.outdegree++;
	}
	
	public int hashCode(){
		return this.uri.hashCode();
	}
	
	public boolean equals(Object o){
		
		// checking for instanceof URI is a later on "improvement" URIImpl should be subclassed
		// but then several changes would be necessary
		if(o instanceof URI){
			return this.uri.equals((URI) o);
		}
		
		if(o instanceof Instance){
			return this.uri.equals( ((Instance) o).getURI());
		}
		return false;
	}
	
	public String toString(){
		return this.uri.toString();
	}
}
